package com.example.avmanagerweb.config.token;

import com.example.avmanagerweb.filter.token.MyFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig  {
    @Autowired
    MyFilter myFilter;

    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        //注册过滤器(初始化过滤器)
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(myFilter);

        //添加过滤的路径,凡是路径带/user就进入过滤器
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.addInitParameter("excludedUrls","/sys-userinfo/login,/sys-userinfo/login2,/fence/getlist,/sys-doc");
        return filterRegistrationBean;
    }
}